package org.bigtree.example.common.frame.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.AbstractRequestLoggingFilter;
import org.springframework.web.filter.CommonsRequestLoggingFilter;

/**
 * @author bigTree
 * @since 2025/6/14
 */
@Configuration
public class LoggerConfig {

    /**
     * 日志明细追踪处理器, 必须设置web日志级别为debug才生效
     */
    @Bean
    public AbstractRequestLoggingFilter requestLoggingFilter() {
        CommonsRequestLoggingFilter logFilter = new CommonsRequestLoggingFilter();
        logFilter.setIncludeHeaders(true);
        logFilter.setIncludeQueryString(true);
        logFilter.setIncludePayload(true);
        // 单位字符
        logFilter.setMaxPayloadLength(1024);
        return logFilter;
    }
}
